<div class="d-flex flex-row-reverse">
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb nb-breadcrumb">
      <li class="breadcrumb-item">
        <a [routerLink]="['/dashboard']">Dashboard</a>
      </li>
      <li class="breadcrumb-item active" aria-current="page">Application Log</li>
    </ol>
  </nav>
  <h1 class="nb-heading-one mr-auto">Application Log</h1>
</div>
<div class="pb-4">
  <button mat-raised-button color="warn" (click)="deleteAllLog()">
    <i class="fa fa-trash"></i> Clear logs</button>
</div>
<div class="d-flex mb-3">
  <div class="mr-3">
        <mat-form-field>
            <input matInput [matDatepicker]="picker" placeholder="Select Start Date" [formControl]="startDate">
            <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
            <mat-datepicker #picker></mat-datepicker>
        </mat-form-field>
    </div>
  <div class="mr-3">
    <mat-form-field>
        <input matInput [matDatepicker]="picker2" placeholder="Select End Date" [formControl]="endDate">
        <mat-datepicker-toggle matSuffix [for]="picker2"></mat-datepicker-toggle>
        <mat-datepicker #picker2></mat-datepicker>
    </mat-form-field>
  </div>
  <div class="mr-3">
    <button mat-mini-fab color="primary" title="Search" (click)="search()">
        <i class="fa fa-search"></i></button>
  </div>
    <div class="mr-3">
        <button mat-mini-fab class="nb-btn btn-green" title="Send email to support" (click)="sendEmailToSupport()">
            <i class="fa fa-paper-plane"></i>
        </button>
    </div>
</div>
<mat-card class="nb-dashboard-table">
    <mat-table #table [dataSource]="dataSource">
      <ng-container matColumnDef="SN">
        <mat-header-cell class="symbol-no" *matHeaderCellDef> SN </mat-header-cell>
        <mat-cell class="symbol-no" *matCellDef="let element let i=index"> {{preIndex+(i+1)}} </mat-cell>
      </ng-container>
      <ng-container matColumnDef="Type">
        <mat-header-cell *matHeaderCellDef> Type </mat-header-cell>
        <mat-cell *matCellDef="let element"> {{element.errorType}} </mat-cell>
      </ng-container>
      <ng-container matColumnDef="Notified">
        <mat-header-cell *matHeaderCellDef>Notified</mat-header-cell>
        <mat-cell *matCellDef="let element"> {{element.errorNotified}} </mat-cell>
      </ng-container>
      <ng-container matColumnDef="Date">
        <mat-header-cell *matHeaderCellDef>Date</mat-header-cell>
        <mat-cell *matCellDef="let element">
          {{changeDateFormat(element.addedOn)}}
        </mat-cell>
      </ng-container>
      <ng-container matColumnDef="Actions">
        <mat-header-cell *matHeaderCellDef>Actions</mat-header-cell>
        <mat-cell  class="nb-icon-cell" *matCellDef="let element let i=index">
          <button mat-mini-fab class="material-icon-sm" color="primary" (click)="showDetail(i)" data-target="#errorModal" data-toggle="modal"
            title="View">
            <i class="fa fa-eye"></i>
          </button>
          <button mat-mini-fab class="material-icon-sm" color="warn" (click)="deleteLogById(element._id)">
            <i class="fa fa-trash"></i>
          </button>
        </mat-cell>
      </ng-container>
      <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
      <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
    </mat-table>
    <div class="p-3 text-center" *ngIf="objResponse?.dataList?.length==0">
        No Records Found
    </div>
      <mat-paginator *ngIf="objResponse?.dataList?.length>0" [length]="totalItems" [pageSize]="perPage" [pageSizeOptions]="pageSizeOptions" (page)="pageChanged($event)">
      </mat-paginator>
</mat-card>
<div class="modal fade" id="errorModal">
  <div class="modal-dialog" >
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Error Stack</h5>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>
      <div class="modal-body">
        <code>{{objLog.errorStack}}</code>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>
